﻿using log4net;
using log4net.Core;
using System.Collections.Generic;
using TransferPost.Beans;

namespace TransferPost.checkpoints
{

    public delegate void DoCheckProcessHandler(MsgBean msg, RtnBean bean);

    /// <summary>
    /// add by zhzhh at 2019年12月14日
    /// 所有的检查点的基类，
    /// 统一方法，统一委托事件进度输出，统一日志记录等各种统一
    /// 以后再说
    /// </summary>
    public class BaseCheckPoint
    {
        protected ILog MyLogger = LogManager.GetLogger(typeof(BaseCheckPoint));

        public DoCheckProcessHandler OnCheckProcessEvent;

        /// <summary>
        /// 继续偷懒
        /// </summary>
        /// <param name="bean"></param>
        protected void PopUpCheckProcessEvent(MsgBean msg, RtnBean bean)
        {
            if (OnCheckProcessEvent != null)
            {
                OnCheckProcessEvent(msg, bean);
            }

            MyLogger.Info(msg.msg);
        }

        /// <summary>
        /// 用于检测前的准备工作
        /// </summary>
        /// <returns></returns>
        public virtual bool PrepareCheck(object obj)
        {
            return true;
        }

        public virtual RtnBean DoCheck(object obj)
        {
            return null;
        }
    }

}
